import request from '@/utils/request'

// ================ 5.0 工资计算工具 ==================
export function getFileData(params) {
  return request({
    url: '/systemTool/getFileData',
    method: 'POST',
    params
  })
}

export function analyzeDataReq(params) {
  return request({
    url: '/systemTool/analyzeData',
    method: 'POST',
    params
  })
}

export function getDataSummary(params) {
  return request({
    url: '/systemTool/getDataSummary',
    method: 'POST',
    params
  })
}

export function exportDataCsv(params) {
  return request({
    url: '/systemTool/exportCsv',
    method: 'GET',
    params,
    responseType: 'blob'
  }).then(res => {
    // 创建 Blob 链接下载
    const url = window.URL.createObjectURL(new Blob([res.data]))
    const link = document.createElement('a')
    link.href = url
    link.setAttribute('download', 'training_records.csv')
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
  })
}

// ================ 基金调仓对比工具 ==================
export function computeFundData(data) {
  return request({
    url: '/systemTool/fundAdjustment',
    method: 'POST',
    data
  })
}
